#include "mainwindow.h"
#include "ui_mainwindow.h"


MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    setMinimumSize(1296,936);
    setMaximumSize(1296,936);

    this->setWindowTitle("魔塔");
    this->scene = new MyQGraphicsScene;
    initScene();
    view = new MyQGraphicsView();


    this->scene->qLabel.setParent(view);
    this->scene->qLabel.hide();
    qDebug()<<"设置场景开始";
    //this->scene->battleView->setParent(view);
    this->scene->qWidget->setParent(view);
    this->scene->qWidget->setGeometry(510,260,600,300);

    QPalette palette2;
    palette2.setBrush(QPalette::Background,QBrush(QPixmap("img/BlankBg.png")));// 使用平滑的缩放方式
    this->scene->qWidget->setPalette(palette2);// 给widget加上背景图
    //qWidget->raise();
    this->scene->qWidget->hide();
    view->setScene(scene);


    qDebug()<<"设置场景结束";
    startTimer(500);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::initScene()
{


}

void MainWindow::timerEvent(QTimerEvent *)
{
    totalSec++;
    this->scene->draw(totalSec%2==0?0:1);
}



